package com.service;

import com.mapper.UserMapper;
import com.model.User;
import com.repository.UserRepository;
import com.vo.RegisterVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {


    @Autowired
    private UserRepository userRepository;

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private UserService userService;

    public List<User> getUserList(){
        //return (List<User>)userRepository.findAll();
        return userMapper.getUserList();
    }

    public User getUserByID(Long id){
        return userMapper.getUserById(id);
    }

    public User getUserByemail(String email){
        return userMapper.getUserByemail(email);
    }

    /**
     * @return true为合法
     * */
    public boolean UserRegisterValidate(String email){
        User userByemail = userService.getUserByemail(email);
        if(userByemail==null) return true;
        return false;
    }

    public User login(String email,String password){
        return userMapper.login(email,password);
    }

    public boolean registerUser(RegisterVO registerVO){
        return userMapper.registerUser(registerVO);
    }
}
